<?php
use  yii\helpers\Url;
use  yii\helpers\Html;
$index   = \backend\modules\models\setting\Menu::findOne(['name'=>'网站首页']);
$index   = $index->getAllContents(1);

$company = \backend\modules\models\setting\Menu::findOne(['name'=>'公司新闻']);
$company = $company->getAllContents(6);

$basic = \backend\modules\models\setting\Menu::findOne(['name'=>'基层动态']);
$basic = $basic->getAllContents(6);

$notice = \backend\modules\models\setting\Menu::findOne(['name'=>'通知公告']);
$notice = $notice->getAllContents(6);

$bid = \backend\modules\models\setting\Menu::findOne(['name'=>'招标公告']);
$bid = $bid->getAllContents(6);

$main    = \backend\modules\models\setting\Menu::findOne(['name'=>'新闻中心','parent_id'=>0]);

$category_up  = \backend\modules\models\setting\LoopBanner::findOne(['title'=>'首页中部背景图']);
$banner_up    = $category_up->banner;

$category_down  = \backend\modules\models\setting\LoopBanner::findOne(['title'=>'首页底部背景图']);
$banner_down    = $category_down->banner;
?>
<main role="main" id="main-wrap">
	<div class="container-lg new-box">
		<div class="row">
			<div class="col-12 text-center big-name">
				<div class="first-title">头条</div>
				<h4><a href="<?= Url::to(['site/content','content_id'=>$index?$index[0]->id:0])?>"><?= Html::encode($index?$index[0]->title:'')?></a></h4>
			</div>
			<?php echo $this->render('top') ?>
			<div class="col-md-6 col-lg-6" style="padding-right:0;padding-left:0;border: 1px solid #e8e8e8;">
				<ul class="nav-new nav nav-pills mb-3" id="pills-tab" role="tablist">
					<li class="nav-item" role="presentation">
						<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">公司新闻</a>
					</li>
					<li class="nav-item" role="presentation">
						<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">基层动态</a>
					</li>
					<li class="nav-item" role="presentation">
						<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact" role="tab" aria-controls="pills-contact" aria-selected="false">通知公告</a>
					</li>
					<li class="nav-item" role="presentation">
						<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-tenders" role="tab" aria-controls="pills-contact" aria-selected="false">招标公告</a>
					</li>
					<li class="nav-item">
						<a href="<?= Url::to(['site/menu','menu_id'=>$main?$main->id:0])?>" class="a-more">更多<i class="iconfont icon-double-arrow"></i></a>
					</li>
				</ul>
				<div class="tab-content" id="pills-new-tabContent">
					<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
						<ul class="list-unstyled">
						<?php if ($company) {?>
							<?php foreach ($company as $one => $first): ?>
								<li class="new-item">
									<div><img src="assets/item-img.png" alt=""><a href="<?= Url::to(['site/content','content_id'=>$first->id])?>"><?= Html::encode($first->title)?></a></div>
									<div><?= Html::encode($first->create_time)?></div>
								</li>
							<?php endforeach ?>
						<?php }?>
						</ul>
					</div>
					<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
						<ul class="list-unstyled">
						<?php if ($basic) {?>
							<?php foreach ($basic as $one => $first): ?>
								<li class="new-item">
									<div><img src="assets/item-img.png" alt=""><a href="<?= Url::to(['site/content','content_id'=>$first->id])?>"><?= Html::encode($first->title)?></a></div>
									<div><?= Html::encode($first->create_time)?></div>
								</li>
							<?php endforeach ?>
						<?php }?>
						</ul>
					</div>
					<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
						<ul class="list-unstyled">
						<?php if ($notice) {?>
							<?php foreach ($notice as $one => $first): ?>
								<li class="new-item">
									<div><img src="assets/item-img.png" alt=""><a href="<?= Url::to(['site/content','content_id'=>$first->id])?>"><?= Html::encode($first->title)?></a></div>
									<div><?= Html::encode($first->create_time)?></div>
								</li>
							<?php endforeach ?>
						<?php }?>
						</ul>
					</div>
					<div class="tab-pane fade" id="pills-tenders" role="tabpanel" aria-labelledby="pills-tenders-tab">
						<ul class="list-unstyled">
						<?php if ($bid) {?>
							<?php foreach ($bid as $one => $first): ?>
								<li class="new-item">
									<div><img src="assets/item-img.png" alt=""><a href="<?= Url::to(['site/content','content_id'=>$first->id])?>"><?= Html::encode($first->title)?></a></div>
									<div><?= Html::encode($first->create_time)?></div>
								</li>
							<?php endforeach ?>
						<?php }?>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="container-lg">
		<div class="row">
			<div class="horizontal-img">
				<?php if ($banner_up) {?>
                    <img src="<?= Html::encode($banner_up[0]->url)?>" alt="">
                <?php }else {?>
                    <img src="assets/horizontal_img1.png" alt="">
                <?php }?>
			</div>
		</div>
	</div>
	<div class="container-lg panel-list">
		<div class="row">
			<?php echo $this->render('product') ?>
			<?php echo $this->render('invest') ?>
			<?php echo $this->render('manage') ?>
		</div>
	</div>

	<div class="container-lg">
		<div class="row">
			<div class="horizontal-img">
				<?php if ($banner_down) {?>
                    <img src="<?= Html::encode($banner_down[0]->url)?>" alt="">
                <?php }else {?>
                    <img src="assets/horizontal_img2.png" alt="">
                <?php }?>
			</div>
		</div>
	</div>


	<?php echo $this->render('middle') ?>
	<?php echo $this->render('linksub') ?>
</main>